// pages/special/special.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    special_type: 2,
  },

  onLoad: function (options) {
    this.loadperson()
  },

  loadperson(){
    let access_token = wx.getStorageSync('access_token')
    wx.request({
      url: 'https://baokang.wshoto.com/wx/listspecialperson',
      data: {
        access_token: access_token,
        special_type:this.data.special_type
      },
      success:(res)=>{
        console.log(res)
        if(res.data.code >= 500){
          app.getLogin().then(function(){
            console.log('二次登录。。。')
          })
        } 
        else if(res.data.code == 1){
          this.setData({
            list:res.data.list
          })
        } 
      }
    })
  },

  changTab: function (e) {
    wx.showLoading({
      title: '加载中...',
    })
    this.setData({
      special_type: e.target.dataset.current
    })
    setTimeout(() => {
      wx.hideLoading()
    }, 500)
    this.loadperson()
  },
  
  add(e){
    console.log(e)
    let person_id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../visit/visit?person_id=' + person_id,
    })
  }
})